const showToast = {
	showToastTitle(title){
		uni.showToast({
			title: title,
			duration: 2000
		});
	},
	showToasting(title='加载中'){
		uni.showLoading({
			title: title
		});
		
		setTimeout(function () {
			uni.hideLoading();
		}, 2000);
	},
	showNoneToast(title){
		uni.showToast({
			title: title,
			icon:'none',
			duration: 2000
		});
	}
}
const waitFunction = {
	//弹窗后关闭弹窗并且进行页面的跳转
	waitRelaunch(title,page){
		uni.showToast({
			title: title,
			icon:'none',
			duration: 2000
		});
		setTimeout(function(){
			uni.reLaunch({
				url:page
			})
		},2000)
	},
	waitNavigateTo(title,page){
		uni.showLoading({
			title: title
		});
		
		setTimeout(function () {
			uni.hideLoading();
			uni.navigateTo({
				url:page,
				success(res) {
					console.log(res)
				},
				fail(err) {
						console.log(err)
				}
			})
		}, 2000);
	},
	waitRedirectTo(title,page){
		uni.showLoading({
			title: title
		});
		setTimeout(function () {
			uni.hideLoading();
			uni.redirectTo({
				url:page,
				fail(err) {
					console.log(err)
				},
				complete(e) {
					console.log(e)
				}
			})
		}, 2000);
	}
}
const check = {
	telphone(data) {
		if(!(/^1[3456789]\d{9}$/.test(data))){
			uni.showToast({
				title: "手机号码不正确",
				icon:'none'
			});     
			return false; 
		} 
		return true
	}
}
//取2位小数
const numberFilter = {
	twoNumherFilter(value){
		// 截取当前数据到小数点后三位
		let tempVal = parseFloat(value).toFixed(3)
		let realVal = tempVal.substring(0, tempVal.length - 1)
		return realVal
	}
}
export default {
	showToast,waitFunction,check,numberFilter
}